package org.example.controller;

import org.example.domain.Market;
import org.example.domain.Production;
import org.example.dto.ProductionDto;
import org.example.result.Result;
import org.example.service.MarketService;
import org.example.service.ProductionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("market")
@RestController
public class MarketController {
    @Autowired
    private MarketService marketService;

    @Autowired
    private ProductionService productionService;

    /**
     * 查询所有零售商
     * @param market
     * @return
     */
    @RequestMapping("list")
    public Result list(Market market){
        List<Market> list = marketService.listAll(market);
        return Result.success(list);
    }


    /**
     * 查询每个零售商里面的原料
     * @param id
     * @return
     */
    @RequestMapping("selectId")
    public Result selectId(Integer id){
        List<ProductionDto> productionDtos = productionService.selectId(id);
        return Result.success(productionDtos);
    }
}
